<form id="form-users" class="form-horizontal" action="/admin/manage/users/add" method="post" accept-charset="utf-8">
    {% raw xsrf_form_html() %}
    <div class="form-group">
        <label for="email" class="col-md-1 control-label">邮箱:</label>
        <div class="col-md-3 col-lg-2">
            <input type="email" id="email" name="email" class="form-control"
                   required data-toggle="popover" data-target="manual" data-placement="top">
        </div>
        <div class="col-md-1">
            <input type="submit" value="添加" class="btn btn-primary">
        </div>
    </div>
</form>
<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th>邮箱</th>
            <th>用户名</th>
            <th>姓名</th>
            <th>角色</th>
            <th>注册时间</th>
            <th>最后登录时间</th>
            <th class="col-md-2">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for i in range(len(lists)) %}
        <tr>
            <td>{{ (page-1)*limit+i+1 }}</td>
            <td>{{ lists[i].email }}</td>
            <td>{{ lists[i].username }}</td>
            <td>{{ lists[i].nickname }}</td>
            {% if lists[i].role == 0 %}
            <td>超级管理员</td>
            {% elif lists[i].role == 1 %}
            <td class="data-col-role-{{ lists[i].id }}">管理员</td>
            {% else %}
            <td class="data-col-role-{{ lists[i].id }}">用户</td>
            {% end %}
            <td>{{ lists[i].registerTime }}</td>
            <td>{{ lists[i].lastLoginTime }}</td>
            <td>
                {% if lists[i].role == 2 %}
                <a class="btn btn-danger btn-enable-role" data-id="{{ lists[i].id }}" data-role="1">设为管理员</a>
                {% elif lists[i].role == 1 %}
                <a class="btn btn-info btn-enable-role" data-id="{{ lists[i].id }}" data-role="2">取消管理员</a>
                {% end %}
                {% if lists[i].role != 0 %}
                <a class="btn btn-warning btn-reset-pwd" data-id="{{ lists[i].id }}" data-email="{{ lists[i].email }}">重置密码</a>
                {% end %}
                {% if lists[i].role != 0 and lists[i].status == 1 %}
                <a class="btn btn-danger btn-enable-user" data-id="{{ lists[i].id }}" data-status="0">禁用</a>
                {% elif lists[i].role != 0 %}
                <a class="btn btn-info btn-enable-user" data-id="{{ lists[i].id }}" data-status="1">启用</a>
                {% end %}
            </td>
        </tr>
        {% end %}
        </tbody>
    </table>
    {% module nav(total_page, page, limit, '/admin/manage/users') %}
</div>